package com.qk.management.mapper;

import com.qk.entity.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author diva
 * @date 2025/10/8 19:58
 * @ProjectName
 */
@Mapper
public interface CourseMapper {
    Integer count(@Param("subject") Integer subject,
                  @Param("name") String name,
                  @Param("price") Integer price,
                  @Param("target") Integer target,
                  @Param("description") String description);

     List<Course> selectByPage(@Param("subject") Integer subject,
                               @Param("name") String name,
                               @Param("price") Integer price,
                               @Param("target") Integer target,
                               @Param("description") String description,
                               @Param("offset") Integer offset,
                               @Param("pageSize") Integer pageSize);

    @Select("SELECT id, subject, name, price, target, description, create_time , update_time FROM course WHERE id = #{id}")
    Course selectById(Integer id);

    @Insert("insert into course(subject,name,price,target,description,create_time,update_time) values(#{subject},#{name},#{price},#{target},#{description},#{createTime},#{updateTime})")
    void insert(Course course);

    @Select("SELECT * FROM course where subject = #{subject}")
    List<Course> selectAll();
    @Delete("delete from course where id= #{id}")
    void deleteById(Integer id);

    void update(Course course);
    @Select("SELECT id, subject, name, price, target, description, create_time , update_time FROM course WHERE subject = #{subject}")
    List<Course> selectBySubject(Integer subject);
}
